package com.example.servlet;

import javax.servlet.ServletContext;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;


@WebServlet(name = "helloServlet", value = "/hello-servlet")
public class HelloServlet extends HttpServlet {


    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        request.setCharacterEncoding("UTF-8");
        String getdata=request.getParameter("get-data");
        System.out.println("get");
        System.out.println(getdata);

        ServletContext context=super.getServletContext();
        String con=(String) context.getAttribute("admin");
        System.out.println(con);
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
        request.setCharacterEncoding("UTF-8");
        String postdata=request.getParameter("post-data");
        System.out.println("post");
        System.out.println(postdata);
    }

    public void destroy() {
    }
}